#include "Headers.h"
#include "StateManager.h"
#include "State_Intro.h"



int main(int argc, char* argv[])
{
	//Set up std::clog and std::cerr to redirect to "log.txt"
	std::streambuf *previousClogBuff, *previousCerrBuff;
	std::ofstream logger("log.txt", std::ios::out | std::ios::app);
	previousClogBuff = std::clog.rdbuf();
	previousCerrBuff = std::cerr.rdbuf();
	std::clog.rdbuf(logger.rdbuf());
	std::cerr.rdbuf(logger.rdbuf());
	clog << getTime() << "Beginning program.\n";

	StateManager stateManager(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, "Vestiges of Light");
	

	while (stateManager.isOpen())
	{
		stateManager.getInput();
		stateManager.update();
		stateManager.draw();
		stateManager.regulateFPS();
	}

	clog << "Restoring clog/cerr and terminating program.\n";
	clog << std::endl;
	clog.rdbuf(previousClogBuff);
	cerr.rdbuf(previousCerrBuff);

	logger.close();
	return 0;
}

